package com.helloandroid.services

import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity

class TestRemoteActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
//        val view = TextView(this)
//        view.textSize = 40f
//        view.setTextColor(Color.RED)
//        view.text = "dfsgsdfgdsfgsdfgdsfgsdfgsdfg"
//        setContentView(view)

        window.setGravity(Gravity.LEFT or Gravity.TOP)
        val layoutParams = window.attributes
        layoutParams.x = 0
        layoutParams.y = 0
        layoutParams.width = 1
        layoutParams.height = 1
        layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE
        layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
        window.attributes = layoutParams

        // 启动服务
        startService(Intent(applicationContext,TestServer::class.java))
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        startService(Intent(applicationContext,TestServer::class.java))
    }
}